package com.neudu.glsb.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;

/**
 * 商品-小料关联表
 * @TableName product_ingredient
 */
@TableName(value ="product_ingredient")
@Data
public class ProductIngredient implements Serializable {
    /**
     * 关联ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 商品ID（关联products表）
     */
    private Integer productId;

    /**
     * 小料ID（关联ingredients表）
     */
    private Integer ingredientId;

    /**
     * 小料额外价格（元）
     */
    private BigDecimal extraPrice;

    /**
     * 是否默认添加：0-否，1-是
     */
    private Integer isDefault;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ProductIngredient other = (ProductIngredient) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getProductId() == null ? other.getProductId() == null : this.getProductId().equals(other.getProductId()))
            && (this.getIngredientId() == null ? other.getIngredientId() == null : this.getIngredientId().equals(other.getIngredientId()))
            && (this.getExtraPrice() == null ? other.getExtraPrice() == null : this.getExtraPrice().equals(other.getExtraPrice()))
            && (this.getIsDefault() == null ? other.getIsDefault() == null : this.getIsDefault().equals(other.getIsDefault()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getProductId() == null) ? 0 : getProductId().hashCode());
        result = prime * result + ((getIngredientId() == null) ? 0 : getIngredientId().hashCode());
        result = prime * result + ((getExtraPrice() == null) ? 0 : getExtraPrice().hashCode());
        result = prime * result + ((getIsDefault() == null) ? 0 : getIsDefault().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", productId=").append(productId);
        sb.append(", ingredientId=").append(ingredientId);
        sb.append(", extraPrice=").append(extraPrice);
        sb.append(", isDefault=").append(isDefault);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}